package com.teamit.web;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.UUID;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.teamit.entity.Employee;
import com.teamit.service.ContactNoteService;

public class ContactNoteServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private ContactNoteService cns=new ContactNoteService();
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String contacts=request.getParameter("contact");
		UUID uuid=UUID.randomUUID();
		if(contacts!=null&&!"".equals(contacts)){
			String newcontact=new String(contacts.getBytes("ISO8859-1"),"UTF-8");
			String contactid=request.getParameter("contactId");
			Employee employee=(Employee) request.getSession().getAttribute("curr_employee");
			cns.save(uuid.toString(), newcontact, contactid, employee.getId());
			response.sendRedirect("contact.jspx");
		}else{
			response.sendRedirect("contact.jspx");
		}
	}

}
